<script setup>
import Layout from "@/components/Layout.vue";
import { ref } from "vue";
import OrderItem from "@/components/OrderItem.vue";
import request from "../utils/request";
import { useCartStore } from "../stores";
const cartStore = useCartStore();
const { cartList } = cartStore;
let orderslist = ref([]);
const userId = localStorage.getItem("userId");
// 订单页获取所有订单
const order = async () => {
  const result = await request.get("/api/v1/orders/" + userId);
  result.data.forEach(() => {
    orderslist.value = result.data;     
  });
};
order();
</script>

<template>
  <layout>
    <div class="main">
      <van-nav-bar title="我的订单" />

      <OrderItem
        v-for="ordersItem in orderslist"
        :ordersItem="ordersItem"
      ></OrderItem>
    </div>
  </layout>
</template>
<style scoped lang="scss">
.main {
  height: 100%;
  background-color: #f8f8f8;
}
</style>
